package com.basic.bio.file;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;

/**
 * @Description:
 * @Date: 2024-03-28 14:44
 * @Author: wz
 **/
public class Client {

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("127.0.0.1", 9090);
            OutputStream os = socket.getOutputStream();
            FileInputStream fis = new FileInputStream("C:\\Users\\Mr.Wang\\Desktop\\t.png");
            int len;
            byte[] buf = new byte[1024];
            while ((len = fis.read(buf)) !=-1){
                os.write(buf,0,len);
            }
            //手动关掉客户端输出，不让服务端一直等  否则服务read会一直读取
            socket.shutdownOutput();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
